home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / PRGMMING / CPP100.ZIP / MANUAL.DOC < prev    next >
Encoding:
Text File  |  1994-11-22  |  17.3 KB  |  407 lines

  1.     ****************
  2.     *  MANUAL.DOC  *
  3.     ****************
  4.  
  5. This manual describes the features of CPP 'The C Programming Package'. This
  6. file also gives a list of comments and advice.
  7.  
  8.     1 - LEGAL STUFF
  9.     ---------------
  10.     This program and all the associated files are Copyright 1993,1994 by
  11. R. NADE and M. GRANDCHAMP. This is NOT a public domain software nor a
  12. Freeware. This program is Shareware. That means you can copy it, distribute
  13. it but must not sell it. You can use it for free only for trying it. If you
  14. decide that this program is good for you, you MUST register. If you do not
  15. register, you MUST NOT use it after a trying period. See REGISTER.DOC
  16.     This program is provided "as is". You use it at your own risks. The
  17. authors cannot be held responsible for any damage caused by the use of The C
  18. Programming Package. In other words, if your dog bytes you, if your computer
  19. writes your applications on its own or if your TV explodes because you use CPP
  20. that is not our fault.
  21.     This program can be freely distributed by BBS, CDROM, Shareware
  22. Distributors, etc. as long as it is distributed completly. Distributors can
  23. charge a nominal fee but it must not exceed 10$ and they must warn their user
  24. that CPP is shareware and that the amount they paid is not for the authors.
  25.     If you are not sure of getting all the files, please contact us. If
  26. you want to know how to get our other releases or if you find a bug or want to
  27. comment or want to see a new feature of CPP, please contact us. If you are a
  28. BBS SysOp or a Shareware Distributor and want to become a registration site,
  29. please contact us.
  30.     If you create a Public Domain software, a Freeware or a Shareware with
  31. The 'C Programming Package', we would be very happy if you sent us a copy of
  32. your work. Thank You.
  33.     A french version of this program is available. Contact us if you do
  34. not manage to get it.
  35.  
  36.         Our address is :        Maxime GRANDCHAMP
  37.                                 Flat 4D - Block G
  38.                                 Sugarwell Court
  39.                                 Meanwood Road
  40.                                 LEEDS
  41.                                 LS7 2DZ
  42.                                 ENGLAND
  43.  
  44.  
  45. This address is available until June 1995. From June 1995, you will be able to
  46. reach us at this one :
  47.                                 Maxime GRANDCHAMP
  48.                                 2 Rue BIR HAKEIM
  49.                                 59160 LOMME
  50.                                 FRANCE
  51.  
  52.  
  53.     2 - PURPOSES OF CPP
  54.     -------------------
  55.     This program does nothing ! This is more than 8,000 lines of C source
  56. code. This code is highly portable and is made for C beginners et C medium
  57. programmers : it will help the beginners to understand how C works and it will
  58. save time to those who already program in C by providing them a user interface
  59. and a lot of common functions such as file manager : find, save, delete, etc.,
  60. configuration menu : printer, colours, sounds, tests, ... All this featuring
  61. fast pull down menu and on-line help !
  62.  
  63.     All you have to do is to fill up the blanks with your own menu names
  64. and with your own help text : Just fill up an ASCII text to make a wonderful
  65. help file ! This help file will be used by your program and will be readable
  66. with an ASCII reader : you do not need HELP.DOC or MANUAL.DOC anymore !
  67.  
  68.     3 - PROGRAM FEATURES
  69.     --------------------
  70.     This program was written in Borland Turbo C, with no use of an external
  71. library. The compilation model is "large". This is a text version of a
  72. wonderful interface. The Graphic version (Full VGA features) will be sent free
  73. to every register user ! This graphic version features a lot of improvements
  74. such as buttons, mouse and keyboard manager, etc. Of course the VGA version
  75. was written using only the standard libraries of Turbo C.
  76.  
  77.     The code is splitted in various files to help you understand how it
  78. works. You already have 7 menus totally blanks. All you have to do is to fill
  79. them up with your own applications and call the appropriate functions in the
  80. file. (Sorry we will not write your application !). You can delete useless
  81. menus, change titles, there is no limit !
  82.  
  83.     4 - USER MANUAL
  84.     ---------------
  85.     It is in the on-line help.
  86.     Choose the last menu (Help) and get a full documentation, splitted in
  87. chapters. Each chapter deals with a menu, except the Help itself. The help
  88. will help you to understand how the program works and will provide you a full
  89. help menu.
  90.         Furthermore, you can access on-line help by typing <F1> when you have
  91. choosen either a menu or just a function ! These are the same help pages as in
  92. the help menu, but they only concern the actual choice.
  93.  
  94.     You can move in the program by one of these three ways :
  95.     - MOUSE : Just click on a menu, on a line or in a box. You can click
  96.     with the left or the right button. If you click in the outside of the
  97.     active window, you will go back to the previous menu.
  98.  
  99.     - KEYBOARD : Two ways : You type Alt + <F> for the Files menu, Alt +
  100. <H> to get the help menu, etc. or when in a menu you just type the highlighted
  101. letter or, it is your choice, you use the cursor arrows and validate with
  102. <Enter>.
  103.  
  104.     All the other possibilities will be told to you by the program itself.
  105.  
  106.     If you did not disable the sound, the program will generate lovely (?)
  107. sounds when he waits a key, an error occurs, etc.
  108.  
  109.     5 - COMMENTS AND ADVICE
  110.     -----------------------
  111.     This is not a programming manual, but only a listing of comments and
  112. advice to use CPP properly.
  113.     You will need to use your C manual to get details on the used
  114. functions (syntax, include, ...).
  115.  
  116.     A.1 - USING THE SOURCE
  117.     ----------------------
  118.     We advice you to create a specific directory, under your C compiler
  119. directory, for instance by typing :
  120.     CD C:\TC <ENTER>
  121.     MD CPP
  122.     CD CPP
  123.     and then copy all the files in this directory by
  124.     COPY A:*.*
  125.     Notice that this example assumes that your C compiler is in C:\TC and
  126. the CPP files are in A:\
  127.  
  128.     A.2 - C COMPILER CONFIGURATION
  129.     ------------------------------
  130.     Because of the size of the files, you need to compile it in 'LARGE'
  131. model. If you did not install your TurboC with this option you will need to
  132. re-install it.
  133.  
  134.     A.3 - OPENING THE PROJECT
  135.     -------------------------
  136.     This manual assumes that you use 'Turbo C'. If you use another
  137. compiler, refer to your documentation.
  138.     As this program is made up of several files, you need to create a
  139. project to link them together. All you have to do is :
  140.     - Open the project menu (Alt-P)
  141.     - Create a new project file
  142.     - Adding all the C files to this project.
  143.  
  144.     A.4 - COMPILATION OPTIONS
  145.     -------------------------
  146.     To get the 'Large' compilation model :
  147.     - Go in the 'Options' menu (Alt-O)
  148.     - Choose 'Compile'
  149.     - Then 'Code Generation'
  150.     - Then select 'Model Large'
  151.  
  152.     A.5 - COMPILING AND LINKING
  153.     ---------------------------
  154.     Now you can try to compile and link the program.
  155.     - Go to the 'Compile' menu (Alt-C)
  156.     - Choose the second line : MAKE EXE
  157.     - And confirm
  158.  
  159.     A.6 - COMMON ERRORS
  160.     -------------------
  161.     If you get the message 'File too large', that is because you did not
  162. selected the right compiling option. Do not forget to choose the 'Large' model.
  163.  
  164.     If you get the message 'Call to undefined function', be sure that you
  165. put ALL the CPP C files in your project. Be sure that in the linking menu, the
  166. Graphics library is activated.
  167.  
  168.     If you get another problem, please contact us.
  169.  
  170.     B - FILES
  171.     ---------
  172.     We cannot do a perfect control of the files because when a file is
  173. opened, the DOS gives it an handle number BUT this number does not change even
  174. if we close the file.
  175.     So, to be able to test whether a file is opened or not, we put the
  176. handle to 0 or -1 when the file is closed. This will avoid a lot of problems.
  177.  
  178.     C - GLOBAL VARIABLES
  179.     --------------------
  180.     In order to limit the number of global variables used in this program
  181. and to avoid using local variables which cause sometimes problems without be
  182. able to fix them, we advice you to split the global variables in two groups
  183. when you declare them :
  184.       - The permament ones, that are used by all the program and that
  185.       represent a configuration parameter (printer, colours, menu choice..)
  186.       - The variables that are used only locally and that are available
  187.       when the sub-program is over.
  188.  
  189.     D - ON-LINE HELP
  190.     ----------------
  191.     There is a full on-line help available in this program. That allows
  192. you to get everything you need just by typing <F1> anywhere in the program.
  193. Please see in the help file, in the configuration menu, how to add help
  194. screens to the existing help file HELP.TXT and how to use the utility program
  195. provided in this menu to create from your HELP.TXT (save it before !) the
  196. HELP.FIC file which is used by the program.
  197.     The purpose of the function is to cut the line feeds and the carriage
  198. returns (ASCII code 0x0d and 0x0a). The file will be 5% smaller but
  199. furthermore, it avoids a display error in the case of a file offset.
  200.     For the specific help, you must respect the format :
  201.         display_help("xxxxxxxx",n1,n2,n3);
  202.         - "xxxxxxxx" is the name of the help. It is the one that is, in
  203.         the help file, at the beginning of the line above the border.
  204.         You can change the menu name without any problem but we advice
  205.         you not to change the call name, otherwise you will have to
  206.         modify the help file. As all this is transparent for the user,
  207.         it has no interest and can cause a lot of errors.
  208.         - n1 is the original offset which is a parameter passed when
  209.         the file is opened. It is useless for the program to search
  210.         the first help screen in the whole file.
  211.         So it jumps over n1 screens and then starts the search.
  212.         Notice that you can add pages without changing this value :
  213.         the program takes around 1 second to search in 100 screens. So
  214.         the change will be useful only if you had a lot of pages.
  215.         Unless you computer is so slow that you must wait several
  216.         seconds before getting the help screen.
  217.         - n2 is the number of the first page you want to display. It
  218.         is the number in the upper-right corner of the page. All the
  219.         pages are numbered in the menu border. So you always start from
  220.         1 for a menu. This allows you to add menu lines.
  221.         If the page number is 0 (zero), this means that the program
  222.         does not worry about pages and displays as long as the help
  223.         name matches.
  224.         - n3 is the number of pages to display. Most of the time it
  225.         will be 1. This does not mean just one page but you are at the
  226.         end of the specific help if you are at page n2+n3. This tip
  227.         allows you to put as many screens as you want as long as the
  228.         page number is always the same. So you can add help screens to
  229.         a function without modifying the program.
  230.         If you put n2=0, then put n3=0.
  231.  
  232.     E - GRAPHICS DRIVER AND FONTS
  233.     -----------------------------
  234.     With Turbo C when you use the graphic mode, you need to have the video
  235.         drivers and the fonts in the program directory.
  236.         You can forget it, your user can delete one of the files and, maybe
  237.         the most important thing, it does not give your program a 'pro look'.
  238.     You can do it in a more lovely way by integrating these files in the
  239.     graphic library (graphics.lib) so that they will be in your program.
  240.     This will increase the program size of 20 KB.
  241.     You can find the information in the documentation but it can be useful
  242.     to memorize a way of doing it :
  243.         1 - Go into the sub-directory where EGAVGA.BGI and *.CHR files
  244.         are.
  245.         2 - Transform these files in object files. For example by
  246.         typing    BGIOBJ EGAVGA <ENTER>
  247.         Then you get a file called EGAVGA.OBJ
  248.         Do the same for the CHR files and get LITT.OBJ and TRIP.OBJ
  249.         3 - Copy these object files in the sub-directory where is
  250.         GRAPHICS.LIB (usually TC\LIB\)
  251.         4 - Add the object files to the library with TLIB by typing
  252.             TLIB GRAPHICS+ EGAVGA <ENTER>
  253.         and so on for all the files. We had to do it file by file
  254.         because TLIB did not want to deal with SANS.OBJ and we do not
  255.         know why.
  256.     Then all you have to do is to declare these drivers in the beginning
  257.     of the program with 'registerbgidriver' and 'registerbgifont' (cf the
  258.     program !).
  259.  
  260.         F - KNOWN PROBLEMS
  261.         ------------------
  262.         All the source code was written in full ANSI-C compatible code except
  263. one function '_setcursortype()' which is provided in the graphics.h library
  264. file of some compilers. This function is not in the TurboC version 1 to 2. You
  265. have to build your own function to hide and show the cursor. This is the code.
  266. All you have to do is to replace the '_setcursortype(_NOCURSOR);' by a call to
  267. the function 'hidecursor()' and '_setcursortype(_NORMALCURSOR)'; by a call to
  268. the function 'showcursor()'. Of course, you will need to add these function to
  269. one of the source file before compiling.
  270.  
  271.         void hidecursor(void)
  272.         {
  273.           union REGS regs;
  274.           regs.h.al=0x01;
  275.           regs.h.ch=32;
  276.           regs.h.cl=14;
  277.           int86(0x0010,®s,®s); /* hide blinking text cursor */
  278.           }
  279.  
  280.         void showcursor(void)
  281.          {
  282.          union REGS regs;
  283.          regs.h.ah=0x01;
  284.          regs.h.ch=1;
  285.          regs.h.cl=14;
  286.          int86(0x0010,®s,®s);   /* restore (show) text cursor */
  287.          }
  288.  
  289. This is just a call to the interrupt 0x10. To understand more about
  290. interrupts, see the following chapter 'How to handle the mouse'.
  291. If you find other problems, please contact us, so we can fix them.
  292.  
  293.         G - BONUS : HOW TO HANDLE THE MOUSE
  294.     -----------------------------------
  295.     To handle the mouse we use the interrupt 0x33.
  296.     An interrupt is a routine that allows you to communicate directly with
  297.     the processor, either via DOS or via BIOS. As its name tells it, you
  298.     ask the computer to stop its current work to do a specific task.
  299.     To do this you put in little processor memories, called registers, some
  300.     numbers that are the code of what you want to do and then you call the
  301.     interrupt. Thus the processor looks at the data codes, do the
  302.     instruction and, if required, returns information by putting them in
  303.     registers where you can get them (for instance the cursor position).
  304.     If you work in assembly language, you need to save the content of the
  305.     registers in the stack and, when you have finished, put back in every
  306.     registers what was in it. Otherwise you can get errors or even crash
  307.     your program.
  308.     If you use the provided functions of your C compiler, you do not have
  309.     to care about all this. All is done by the compiler.
  310.     There are several types of registers :
  311.         - General registers (AX,BX,CX,DX) which are composed of 16
  312.         bits that you can access in once (AX for instance) or two
  313.         bytes. In this case, we speak of AH (High byte, bits 7 to 15)
  314.         and AL (low byte, bits 0 to 7). The access is different. If
  315.         you want to enter just one byte, for example to reset AL
  316.         register to 0 you write inreg.h.al=0x00;
  317.         The content of AH will not be modified.
  318.         On the other hand, if you write inreg.x.ax=0x00; you will put
  319.         the whole AX register to 0 (same as 0x0000).
  320.         - Other 16 bits general registers (SP,BP,SI,DI).
  321.         - 16 bits segmentation registers (CS,DS,SS,ES,IP)
  322.         - State and control register.
  323.     To handle the mouse, you will just use the first 4.
  324.  
  325.     Interrupt 0x33, functions
  326.     -------------------------
  327.     Let's see how to use it to control the mouse.
  328.     To avoid doing an error, we put the data code in hexadecimal.
  329.  
  330.     Test whether the mouse is here
  331.     ------------------------------
  332.     Input    AX = 0x00
  333.     Output    AX = 0    No mouse or no driver loaded
  334.         AX = -1 Mouse
  335.         BX = number of buttons
  336.  
  337.     Set mouse cursor on
  338.     -------------------
  339.     Input    AX = 0x01
  340.     Output
  341.  
  342.     Hide mouse cursor
  343.     -----------------
  344.     Input    AX = 0x02
  345.     Output
  346.  
  347.     Get mouse position and buttons state
  348.     ------------------------------------
  349.     Input    AX = 0x03
  350.     Output    BX = buttons state    1 = left button pressed
  351.                     2 = right button pressed
  352.                     3 = right and left buttons pressed
  353.                     4 = middle button pressed
  354.         CX = column (x) in pixels
  355.         DX = line (y) in pixels
  356.  
  357.     Put the mouse in (x,y)
  358.     ----------------------
  359.     Input    AX = 0x04
  360.         BX = column (x)
  361.         CX = line (y)
  362.     Output
  363.  
  364.     Get the number of times the button was pressed
  365.     ----------------------------------------------
  366.     Input    AX = 0x05
  367.         BX = button to check (cf function 0x03)
  368.     Output    AX = buttons status
  369.         BX = Number of press since the last call
  370.         CX = column (x) at the last press
  371.         DX = line (y) at the last press
  372.     Notice that the counter is reset to 0 each time you call this function
  373.  
  374.     Get the number of times the button was released
  375.     -----------------------------------------------
  376.     Input    AX = 0x06
  377.         BX = button to check (cf function 0x03)
  378.     Output    AX = buttons status
  379.         BX = Number of releases since the last call
  380.         CX = column (x) at the last release
  381.         DX = line (y) at the last release
  382.     Notice that the counter is reset to 0 each time you call this function
  383.  
  384.     Change of the horizontal limits
  385.     -------------------------------
  386.     Input    AX = 0x07
  387.         BX = Left mouse limit (column in pixels)
  388.         CX = Right mouse limit (column in pixels)
  389.     Output
  390.  
  391.     Change of the vertical limits
  392.     -----------------------------
  393.     Input    AX = 0x08
  394.         BX = Top mouse limit (column in pixels)
  395.         CX = Bottom mouse limit (column in pixels)
  396.  
  397.     Use the function 7 and the function 8 to define a window where to
  398.     limit the mouse.
  399.  
  400. The registered version of CPP includes the function 9 that allows you to
  401. redefine the mouse shape in graphic mode. It is provided with a lot of common
  402. mouse shapes such as various Arrows, Pointing Hand, ...
  403.  
  404.  
  405.  
  406.  
  407.